<template>
  <div>
    <h1>Didi</h1>
    <h2>{{count}}</h2>
    <button @click="beybey">取消订阅</button>
  </div>
</template>

<script>
import PubSub from 'pubsub-js'
export default {
    name:"Didi",
    data(){
        return {
            count:0,
            pubId:null
        }
    },
    mounted(){
       this.pubId =   PubSub.subscribe('count',(_,count) => {
            this.count = count
        })
    },
    methods:{
        beybey(){
            PubSub.unsubscribe(this.pubId)
        }
    }
}
</script>

<style>

</style>